#!/bin/sh

if /usr/bin/test -n "${DEVPATH}" && /usr/bin/test -e "/sys${DEVPATH}" ; then
    input_path=`/usr/bin/dirname /sys${DEVPATH}`
    input_name=
    if /usr/bin/test -e ${input_path}/name ; then
        input_name=`/bin/cat ${input_path}/name`
    fi
    if /usr/bin/test -n "${input_name}" ; then
        if /usr/bin/test "${input_name}" = "Nintendo Wiimote" ; then
            input_phys=
            if /usr/bin/test -e ${input_path}/phys ; then
                input_phys=`/bin/cat ${input_path}/phys`
            fi
            if /usr/bin/test -n "${input_phys}" ; then
                . /etc/conf
                if   /usr/bin/test "${input_phys}" = "00:00:00:00:00:00"       ; then
                    /bin/echo "wiimote"
                elif /usr/bin/test "${input_phys}" = "${MM_WIIMOTE_ADDRESS_0}" ; then
                    /bin/echo "wiimote-0"
                elif /usr/bin/test "${input_phys}" = "${MM_WIIMOTE_ADDRESS_1}" ; then
                    /bin/echo "wiimote-1"
                elif /usr/bin/test "${input_phys}" = "${MM_WIIMOTE_ADDRESS_2}" ; then
                    /bin/echo "wiimote-2"
                elif /usr/bin/test "${input_phys}" = "${MM_WIIMOTE_ADDRESS_3}" ; then
                    /bin/echo "wiimote-3"
                fi
            fi
        fi
    fi
fi

exit 0
